﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DLL;
using PagedList;

namespace BLL
{
    public class BillService
    {
        private BillRepo m_Repo;

        public BillService()
        {
            m_Repo = new BillRepo();
        }

        public void Add(Bill bill)
        {
            m_Repo.Add(bill);
        }

        public void Update(Bill bill)
        {
            m_Repo.Update(bill);
        }

        public Bill GetById(int billId)
        {
            return m_Repo.GetById(billId);
        }

        public Bill GetPrintedBill(int billId)
        {
            return m_Repo.GetPrintedBill(billId);
        }

        public List<Bill> GetActiveBills()
        {
            return m_Repo.GetActiveBills();
        }

        public bool Delete(int billId)
        {
            return m_Repo.Delete(billId);
        }

        public pGetNextBillIdAndIndex_Result GetNextIndexInDay()
        {
            return m_Repo.GetNextIndexInDay();
        }

        public bool DeleteBillAndDetail(int billId)
        {
            return m_Repo.DeleteBillAndDetail(billId);
        }

        public List<pSearchBill_Result> SearchBill(DateTime? fromDate, DateTime? toDate,
           int? billId, int? billIndex, bool? isPrinted, string customerName, int? customerPhone, string productName, out int totalPrice)
        {
            return m_Repo.SearchBill(fromDate, toDate, billId, billIndex, isPrinted, customerName,
                customerPhone, productName, out totalPrice);
        }

        public bool Sale(int billId)
        {
            return m_Repo.Sale(billId);
        }

        public List<pSellStatistics_Result> SellStatistics(
            DateTime fromDate, DateTime toDate, int? productTypeId, int? producerId, string productName,
            out int totalSale, out int totalDiscount, out int totalBenefit, out int totalInput)
        {
            return m_Repo.SellStatistics(fromDate, toDate, productTypeId,
                producerId, productName, out totalSale, out totalDiscount, out totalBenefit, out totalInput);
        }
    }
}
